home *** CD-ROM | disk | FTP | other *** search
- /* ==============================
-
- Program name: dDriver.c
- Function: This is the main module for this program.
- History: 10/3/89 by Kirk Chase.
-
- ================================= */
-
- #include "String.h"
- #include "Messenger.h"
-
- #define NIL 0
-
- /* External variables & routines */
-
-
- /* ====================================== */
- void main(void);
- /* ====================================== */
-
- void main()
- {
- char doneFlag;
- char ch;
- short code;
- short theMenu,theItem;
- long mResult;
- WindowPtr whichWindow;
- EventRecord myEvent;
- Rect tempRect;
- GrafPtr SavePort;
- int dummy;
-
- MoreMasters();
- InitGraf(&thePort);
- InitFonts();
- FlushEvents(everyEvent,0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NIL);
- InitCursor();
-
- OpenResFile("\pdDriver.π.RSRC");
-
-
- doneFlag = FALSE;
-
- InitMyMenus();
-
- InitMessage();
- dummy = ArrangeMessage(1);
-
- do {
- SystemTask();
-
- if (GetNextEvent(everyEvent, &myEvent)) {
- code = FindWindow(myEvent.where, &whichWindow);
-
- switch (myEvent.what) {
- case mouseDown:
- if (code == inMenuBar) {
- mResult = MenuSelect(myEvent.where);
- theMenu = HiWord(mResult);
- theItem = LoWord(mResult);
- HandleMenu(&doneFlag,theMenu,theItem);
- }
-
- if ((code == inDrag)&&(whichWindow != NIL)) {
- tempRect = screenBits.bounds;
- SetRect(&tempRect, tempRect.left + 10, tempRect.top + 25, tempRect.right - 10, tempRect.bottom - 10);
- DragWindow(whichWindow, myEvent.where, &tempRect);
- }
-
- if (code == inContent) {
- if (whichWindow != FrontWindow()) {
- SelectWindow(whichWindow);
- } else {
- SetPort(whichWindow);
- }
- }
-
- if (code == inSysWindow)
- {
- SystemClick(&myEvent, whichWindow);
- }
- break;
-
- case keyDown:
- case autoKey:
- ch = myEvent.message & charCodeMask;
- if (myEvent.modifiers & cmdKey) {
- mResult = MenuKey(ch);
- theMenu = HiWord(mResult);
- theItem = LoWord(mResult);
- if (theMenu != 0)
- HandleMenu(&doneFlag, theMenu, theItem);
- }
- break;
-
- case updateEvt:
- whichWindow = (WindowPtr)myEvent.message;
- GetPort(&SavePort);
- BeginUpdate(whichWindow);
- SetPort(whichWindow);
-
- EndUpdate(whichWindow);
- SetPort(SavePort);
- break;
-
- case diskEvt:
- if (HiWord(myEvent.message) != 0) {
- myEvent.where.h = ((screenBits.bounds.right - screenBits.bounds.left) / 2) - (304 / 2);
- myEvent.where.v = ((screenBits.bounds.bottom - screenBits.bounds.top) / 3) - (104 / 2);
- InitCursor();
- theItem = DIBadMount(myEvent.where, myEvent.message);
- }
- break;
-
- case activateEvt:
- if ((whichWindow != NIL) && (myEvent.modifiers & activeFlag)) {
- SelectWindow(whichWindow);
- }
- break;
-
- default:
- break;
-
- }
-
- }
- } while (doneFlag == FALSE);
-
- } /* end of main */